<?php

namespace App\Http\Requests;

//秒杀字段验证
class KillRequest extends BaseFormRequest
{

    public function rules()
    {

        return [
            //goodData
            'coverimage' => 'required',
            'goodstitle' => 'required',
            'voucherprice' => 'required',
            //'voucherprice' => 'required|integer',
            //'commissionrate' => 'required|between:min:0.01,max:100',
            'commissionrate' => 'required',
           // 'commissiontype' => 'required|min:1,max:4',
            'commissiontype' => 'required',
            'copywritingimage' => ['required'],
            'goodslink' => ['required', 'string', 'regex:/(?<=(\?|&)id=)\w+/i'],
            'copywriting' => ['required'],
            //goodCoupon
            'couponmoney' => 'required|min:0.01',
            'coupontotal' => 'required|integer',
            'couponlink' => 'required|string|url',
            //'couponstarttime' => 'required|date_format:"Y-m-d H:i:s"',
            //'couponendtime' => 'required|date_format:"Y-m-d  H:i:s"',
            //goodShopData
            'activitytype' => 'required|integer',


            //killdata
            //'startdate' => 'required|date_format:"Y-m-d"',
            'startfield' => ['required', 'regex:/^(20|21|22|23|[0-1]\d):[0-5]\d$/'],
            'keyword' => 'required',
            'friends' => 'required',
        ];

    }

    //定义出错后的message信息：
    public function messages()
    {
        return [
            'coverimage.required' => '主封面必填',
            'goodstitle.required' => '商品标题必填',
            'voucherprice.required' => '劵后价格必填',
            // 'voucherprice.integer' => '劵后价格为数字',
            'commissionrate.required' => '佣金比例必填',
            //'commissionrate.between' => '佣金比例最小为0.01,最大为1',
            'commissiontype.required' => '佣金类型必填',
            'copywritingimage.required' => '文案主图必填',
           // 'copywritingimage.json' => '文案主图为json格式',
            'goodslink.required' => '商品链接必填',
            'goodslink.string' => '商品链接为字符串',
            'goodslink.regex' => '商品链接未含id',
            'copywriting.required' => '文案内容必填',
            //goodCoupon
            'couponmoney.required' => '券面额必填',
            'couponmoney.number' => '券面额为数字',
            'couponmoney.min' => '券面额最小为0.01',
            'coupontotal.required' => '券总数必填',
            'coupontotal.integer' => '券总数必须为数字',
            'couponlink.required' => '优惠券链接必填',
            'couponlink.string' => '优惠券链接为字符串',
            'couponlink.url' => '优惠券链接为url格式',
            //'couponstarttime.required' => '券生效时间必填',
            //'couponstarttime.date_format' => '券生效时间格式不对',
            //'couponendtime.required' => '券失效时间必填',
            //'couponendtime.date_format' => '券失效时间格式不对',
            //goodShopData
            'activitytype.required' => '活动类型必填',
            'activitytype.between' => '活动类型为数字',

            //killdata
            //'startdate.required' => '秒杀开始时间必填',
            //'startdate.date_format' => '秒杀开始时间格式不对',
            'startfield.required' => '秒杀场次必填',
            'startfield.regex' => '秒杀场次格式不对',
            'keyword.required' => '关键字必填',
            'friends.required' => '朋友圈文案必填',
        ];

        //startdate  秒杀日期 goods_kill
        //startfield  秒杀场次 goods_kill
        //coverimage  主封面  goods
        //goodstitle  淘宝商品标题  goods
        //keyword  关键词  goods_kill
        //voucherprice 劵后价格 goods
        //commissionrate 佣金比例 goods
        //commissiontype 佣金类型 goods
        //couponmoney 券面额 goods_coupon
        //coupontotal  券总数 goods_coupon
        //copywritingimage 文案主图 goods
        //goodslink 商品链接 goods
        //couponlink 优惠券链接 goods_coupon
        //copywriting->shoppingguide 文案内容(多个)  --导购 goods
        //activitytype 活动类型  goods_shop
        //couponstarttime 券开始时间  goods_coupon
        //couponendtime 券失效时间  goods_coupon
        //copywriting->kill 完整秒杀文案  goods
    }


}
